<template>
	<view class="main">
		<view class="ul">
			<view class="li justify_between_center typeface" v-if="item.isShow" v-for="(item, index) in menuList" :key="index"
				@click="onClick(item)">
				<text class="title fz32">{{ item.name }}</text>
				<u-icon name="arrow-right" color="#333" size="28rpx"></u-icon>
			</view>
		</view>

		<u-modal :show="signOutPopup" :showConfirmButton='false' :closeOnClickOverlay="true" overlayOpacity="0.7"
			content="提交申请后，您将无法登录、使用本帐号，账户注销后，您在本平台的所有权益也将一并失效。">
		</u-modal>
	</view>
</template>

<script>
import { isDelUser } from '@/api/my.js'
export default {
	data() {
		return {
			userInfo: {},
			menuList: [{
				name: '修改登录密码',
				url: '/pages/my/settings/editPassword?type=2',
				isShow: true
			}, {
				name: '设置登录密码',
				url: '/pages/my/settings/editPassword?type==1',
				isShow: true
			}, {
				name: '账号注销',
				url: '/pages/my/settings/SignOUT',
				isShow: true,
				handler: 'isDelUser'
			},],
			platform: '',
			signOutPopup: false, //注销弹窗提示
		};
	},
	onLoad(e) {
		this.userInfo = uni.getStorageSync('userInfo') || {}
		// 是否有密码
		if (this.userInfo.password != '') {
			this.menuList[1].isShow = false;
		} else {
			this.menuList[0].isShow = false;
		}

	},
	methods: {
		onClick(item) {
			if (item.handler) {
				this[item.handler]();
			} else if (item.url) {
				uni.navigateTo({
					url: item.url
				})
			}
		},
		isDelUser() {
			isDelUser().then(res => {
				if (res.code == 0) { //0是未注销  1是已注销
					uni.navigateTo({
						url: '/pages/my/settings/SignOUT'
					})
				} else {
					this.signOutPopup = true
					setTimeout(() => {
						this.signOutPopup = false
					}, 3000)
				}
			})
		},
	},
}
</script>

<style lang="scss" scoped>
/deep/.u-modal__content {
	text-align: center;
}

.main {
	position: relative;
	min-height: 100vh;
	background-color: #F6F6F6;
	overflow: hidden;

	.ul {
		background: #FFFFFF;
		border-radius: 15rpx;
		margin-top: 18rpx;
		overflow: hidden;

		.li {
			padding: 0 30rpx 0 46rpx;
			height: 120rpx;
		}
	}
}
</style>
